﻿using Ledict.Core.Data;
using System;
using System.Collections.Generic;
using System.Data.Common;
using System.Linq;
using System.Text;
using System.Threading.Tasks;


namespace Ledict.ConditionExtract.DAL
{
    /// <summary>
    /// 用户DAL
    /// </summary>
    public class CoreUserDAL
    {
        private string DbName;
        public CoreUserDAL()
        {
            DbName = "UserJurisdiction";
        }

        /// <summary>
        /// 添加用户
        /// </summary>
        /// <param name="uo"></param>
        /// <returns></returns>
        //public bool AddUser(UserObject uo)
        //{
        //    StringBuilder strSql = new StringBuilder();
        //    strSql.Append(@" insert into T_Core_User(O_UserId,O_UserName,O_UserDisplayName,O_PassWord,O_PeriodBegin,O_UserDepartId)values(NEWID(),@O_UserName,@O_UserDisplayName,@O_PassWord,GETDATE(),@O_UserDepartId) ");
        //    Database oBase = DatabaseFactory.CreateDatabase(DbName);
        //    DbCommand oCmd = oBase.GetSqlStringCommand(strSql.ToString());
        //    oBase.AddInParameter(oCmd, "@O_UserName", System.Data.DbType.String, uo.m_userName);
        //    oBase.AddInParameter(oCmd, "@O_UserDisplayName", System.Data.DbType.String, uo.m_userDisplayName);
        //    oBase.AddInParameter(oCmd, "@O_PassWord", System.Data.DbType.String, uo.m_passWord);
        //    oBase.AddInParameter(oCmd, "@O_UserDepartId", System.Data.DbType.String, uo.m_userDepartId);
        //    if (oBase.ExecuteNonQuery(oCmd) > 0)
        //    {
        //        return true;
        //    }
        //    else
        //    {
        //        return false;
        //    }
        //}

        /// <summary>
        /// 修改用户密码
        /// </summary>
        /// <param name="uo"></param>
        /// <returns></returns>
        //public bool UpdateUser(UserObject uo)
        //{
        //    StringBuilder strSql = new StringBuilder();
        //    strSql.Append(" update T_Core_User set O_PassWord=@O_PassWord where O_UserId=@O_UserId ");
        //    Database oBase = DatabaseFactory.CreateDatabase(DbName);
        //    DbCommand oCmd = oBase.GetSqlStringCommand(strSql.ToString());
        //    oBase.AddInParameter(oCmd, "@O_PassWord", System.Data.DbType.String, uo.m_passWord);
        //    oBase.AddInParameter(oCmd, "@O_UserId", System.Data.DbType.String, uo.m_userId);
        //    if (oBase.ExecuteNonQuery(oCmd) > 0)
        //    {
        //        return true;
        //    }
        //    else
        //    {
        //        return false;
        //    }
        //}
    }
    
}
